package org.adream.account.dao;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.adream.account.entity.CoachPlanRoleEntity;
import org.adream.account.entity.UserVerifyEntity;
import org.adream.account.rest.api.model.DataTableRequest;
import org.apache.ibatis.annotations.Param;

@BaseMybatisDao
public interface UserVerifyDao {
	
	int addUserVerify(UserVerifyEntity userVerifyEntity);
	
	int deleteUserVerify(UserVerifyEntity userVerifyEntity);
	
	int updateUserVerify(UserVerifyEntity userVerifyEntity);
	
	List<UserVerifyEntity> queryVerifiesByDr(@Param("dr") Integer dr);
	
	List<UserVerifyEntity> queryVerifiesByUidAndDr(@Param("uid") String uid,@Param("dr") Integer dr);
	
	List<UserVerifyEntity> queryVerifiesByRleIdAndDr(@Param("rleId") String rleId,@Param("dr") Integer dr);
	
	UserVerifyEntity queryVerifyByUidAndRleId(@Param("uid") String uid,@Param("rleId") String rleId);

	UserVerifyEntity queryVerifyByUidAndRleIdAndDr(@Param("uid") String uid,@Param("rleId") String rleId,@Param("dr") Integer dr);
	
	List<UserVerifyEntity> queryVerifiesBySomeInfo(@Param("uid") String uid, @Param("realName") String realName,@Param("rleId") String rleId,@Param("state") Integer state,@Param("dr") Integer dr);
	/**
	 * 	查询 状态 1，2 的 
	 * @return
	 */
	ArrayList<UserVerifyEntity> queryVerifyByUid(@Param("uid") String uid);
	 
	ArrayList<UserVerifyEntity> queryUserVerifyByMts(@Param("mts") String mts);
	
	UserVerifyEntity queryTeacherInfo(@Param("uid") String uid,@Param("rleId") String rleId,@Param("dr") Integer dr);

	List<Map<String, Object>> queryUserVerifyInfo(String uid);
	
	//审核"身份认证"
	int checkVerify(UserVerifyEntity verify);
	
	//根据uid,state,dr统计身份认证
	int countVerifyByUidAndStateAndDr(@Param("uid") String uid,@Param("state") Integer state,@Param("dr") Integer dr);
	
	//查询用户 所有身份信息 返回 还包括 学校名字 角色名字 等
	List<UserVerifyEntity> queryDetailByUidAndDr(@Param("uid") String uid,@Param("dr") Integer dr);
	
	//根据state,dr查询身份认证
	List<UserVerifyEntity> queryVerifyByStateAndDr(@Param("state") Integer state, @Param("dr") Integer dr);

	int updateAutoCheckResult(UserVerifyEntity userVerifyEntity);
	
	CoachPlanRoleEntity queryCoachPlanRole(@Param("uid") String uid, @Param("rleId") String rleId, @Param("state") Integer state, @Param("dr") Integer dr);
	
	//查询用户详情的认证信息
	List<UserVerifyEntity> queryDetailVerifiesByUidAndDr(@Param("uid") String uid, @Param("dr") Integer dr);
	
	//查询认证成功但已过期的认证信息
	List<UserVerifyEntity> queryExpireVerifiesByStateAndDr(@Param("state") Integer state, @Param("dr") Integer dr);

	List<UserVerifyEntity> queryByRoleIds(@Param("uid")String uid, @Param("roleIds")List<String> roleIds);
	
	/**
	 * 查询用户 其他角色的认证情况（审核中和 审核成功的）
	 * @param uid
	 * @param roleIds
	 * @return
	 */
	int queryCountNotInRoleIds(@Param("uid")String uid, @Param("roleIds")List<String> roleIds);
	
	int replaceVerifyByUidAndRleId(UserVerifyEntity verifyEntity);
	
	//查询去远方角色
	UserVerifyEntity queryGoFarAwayVerify(@Param("uid")String uid, @Param("dr")Integer dr);

	//查询教练计划
	UserVerifyEntity querycoachPlanVerify(@Param("uid")String uid, @Param("dr")Integer dr);
	//查询社区认证
	UserVerifyEntity queryAdreamCenterVerify(@Param("uid")String uid, @Param("dr")Integer dr);

	List<UserVerifyEntity> queryVerifiesByDataTable(DataTableRequest dtr);

	List<Map<String, Object>> queryVerifiesByRleIdAndStateAndWhere(@Param("rleId")String rleId, @Param("state")String state, @Param("where")String where);
	
	//更新认证表中的sid字段
	int updateSidVerifiesByOriSid(@Param("sid") String sid, @Param("oriSid") String oriSid);
	
	//查询校长训练营
	UserVerifyEntity queryHtcVerify(@Param("uid")String uid, @Param("dr")Integer dr);
	
	//查询该用户包含学校认证的信息
	List<UserVerifyEntity> queryContainSchoolVerifiesByUidAndDr(@Param("uid") String uid,@Param("dr") Integer dr);
	
	//更新用户包含学校信息的认证
	int updateSidVerifiesByUidAndDr(@Param("uid") String uid, @Param("sid") String sid, @Param("dr") Integer dr);

	Map<String, String> queryVerifyInfoByUidAndRleId(@Param("uid")String uid, @Param("rleId")String rleId);
}